﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class UserControl_tin_tuc_chi_tiet : System.Web.UI.UserControl
{
    #region Properties
    protected DataTable dtChiTiet;
    protected string strUserControl = "UserControl_tin_tuc_chi_tiet";
    protected string strTieude;
    protected string strTomtat;
    protected string strTI_ID;
    protected string strCD_ID;
    protected string strTieudekhongdau;
    protected string strNoidung;
    protected string strNgaydangtin;
    protected string strNguontin;
    protected string strLuotxem;


    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        xGetParam();
    }

    /// <summary>
    /// Lấy chi tiết tin tức, set title, description.
    /// Author:NguyenTv
    /// Create date:05/09/2013
    /// </summary>
    private void xgetDetailPhongTro(string strMaTin)
    {
        try
        {
            DataSet dsTinTuc = clsTinTuc.TinTuc_FND(1,1,strMaTin,"","",-1,-1,1);
            dtChiTiet = dsTinTuc.Tables[0];

            if (dtChiTiet == null) return;
            if (dtChiTiet.Rows.Count <= 0) return;

            strTieude = dtChiTiet.Rows[0]["ti_tieude"].ToString();
            strTomtat = dtChiTiet.Rows[0]["ti_tomtat"].ToString();
            this.Page.Title = strTieude;
            this.Page.MetaDescription = strTomtat;
            this.Page.MetaKeywords = OsPortal.oStringHelper.TachChuoi(strTieude);

            strTI_ID = dtChiTiet.Rows[0]["TI_ID"].ToString().ToLower();
            strCD_ID = dtChiTiet.Rows[0]["CD_ID"].ToString();
            strTieudekhongdau = dtChiTiet.Rows[0]["ti_tieudekhongdau"].ToString();
            strNoidung = dtChiTiet.Rows[0]["ti_noidung"].ToString();
            strNgaydangtin = OsPortal.oStringHelper.ConvertDateTime_to_String(Convert.ToDateTime(dtChiTiet.Rows[0]["ti_ngaydangtin"]), 1);
            strNguontin = dtChiTiet.Rows[0]["ti_nguontin"].ToString();
            strLuotxem = dtChiTiet.Rows[0]["ti_luotxem"].ToString();

            hdChuyenMuc.Value = strCD_ID;

        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strUserControl, "xgetDetailPhongTro()", ex.ToString());
        }
    }



    /// <summary>
    /// Lấy mã tin tức trên URL
    /// Author:NguyenTv
    /// Create date:05/09/2013
    /// </summary>
    private void xGetParam()
    {
        string strTenPhong = clsCommon.fncGetRoute(this.Page, "param1");
        string[] strLstKey = strTenPhong.Split('-');
        string strMaTin = strLstKey[strLstKey.Length - 1];
        xgetDetailPhongTro(strMaTin);
    }

}